
<%@ page import="net.comic.entities.Comic" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="comic.edit" default="Edit Comic" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="Home" /></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="comic.list" default="Comic List" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="comic.new" default="New Comic" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="comic.edit" default="Edit Comic" /></h1>
            <g:if test="${flash.message}">
            <div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}" /></div>
            </g:if>
            <g:hasErrors bean="${comicInstance}">
            <div class="errors">
                <g:renderErrors bean="${comicInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <g:hiddenField name="id" value="${comicInstance?.id}" />
                <g:hiddenField name="version" value="${comicInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr>
                                <td>
                                    <label><g:message code="comic.name" default="Name" />:</label>
                                </td>
                                <td class="value ${hasErrors(bean: comicInstance, field: 'name', 'errors')}">
                                    <g:textField name="name" maxlength="50" value="${fieldValue(bean: comicInstance, field: 'name')}" />

                                </td>
                            </tr>
                        
                            <tr>
                                <td valign="top" class="name">
                                    <label for="description"><g:message code="comic.description" default="Description" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'description', 'errors')}">
                                    <g:textArea name="description" rows="5" cols="40" value="${fieldValue(bean: comicInstance, field: 'description')}" />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="author"><g:message code="comic.author" default="Author" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'author', 'errors')}">
                                    <g:select name="author.id" from="${net.comic.entities.Author.list()}" optionKey="id" value="${comicInstance?.author?.id}" noSelection="['null': '']" />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="comments"><g:message code="comic.comments" default="Comments" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'comments', 'errors')}">
                                    <g:select name="comments"
from="${net.comic.entities.Comment.list()}"
size="5" multiple="yes" optionKey="id"
value="${comicInstance?.comments}" />


                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="createdBy"><g:message code="comic.createdBy" default="Created By" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'createdBy', 'errors')}">
                                    <g:select name="createdBy.id" from="${net.comic.entities.User.list()}" optionKey="id" value="${comicInstance?.createdBy?.id}"  />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dateCreated"><g:message code="comic.dateCreated" default="Date Created" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'dateCreated', 'errors')}">
                                    <g:datePicker name="dateCreated" value="${comicInstance?.dateCreated}"  />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="disabled"><g:message code="comic.disabled" default="Disabled" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'disabled', 'errors')}">
                                    <g:checkBox name="disabled" value="${comicInstance?.disabled}" />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="imagePath"><g:message code="comic.imagePath" default="Image Path" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'imagePath', 'errors')}">
                                    <g:textField name="imagePath" value="${fieldValue(bean: comicInstance, field: 'imagePath')}" />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="lastUpdated"><g:message code="comic.lastUpdated" default="Last Updated" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'lastUpdated', 'errors')}">
                                    <g:datePicker name="lastUpdated" value="${comicInstance?.lastUpdated}"  />

                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="page"><g:message code="comic.page" default="Page" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'page', 'errors')}">
                                    
<ul>
<g:each in="${comicInstance?.page}" var="pageInstance">
    <li><g:link controller="page" action="show" id="${pageInstance.id}">${pageInstance?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="page" params="['comic.id': comicInstance?.id]" action="create"><g:message code="page.new" default="New Page" /></g:link>


                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="ratings"><g:message code="comic.ratings" default="Ratings" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'ratings', 'errors')}">
                                    <g:select name="ratings"
from="${net.comic.entities.Rate.list()}"
size="5" multiple="yes" optionKey="id"
value="${comicInstance?.ratings}" />


                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="tags"><g:message code="comic.tags" default="Tags" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'tags', 'errors')}">
                                    <g:select name="tags"
from="${net.comic.entities.Tag.list()}"
size="5" multiple="yes" optionKey="id"
value="${comicInstance?.tags}" />


                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="rate"><g:message code="comic.rate" default="Rate" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: comicInstance, field: 'rate', 'errors')}">
                                    <g:textField name="rate" value="${fieldValue(bean: comicInstance, field: 'rate')}" />

                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'update', 'default': 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'delete', 'default': 'Delete')}" onclick="return confirm('${message(code: 'delete.confirm', 'default': 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
